<!-- 班级编辑弹窗 -->
<template>
  <div>
    <el-form
        inline size="mini"
        :model="where"
        class="ele-form-search"
        @keyup.enter.native="reload"
        @submit.native.prevent>
      <el-form-item>
        <el-input clearable v-model="where.keyword" placeholder="请输入学生姓名/学号"/>
      </el-form-item>
      <el-form-item>
        <el-date-picker v-model="where.date" type="month" placeholder="选择日期" style="width: 125px"></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button size="mini" type="primary" icon="el-icon-search" class="ele-btn-icon" @click="reload">查询
        </el-button>
        <el-button size="mini" @click="reset">重置</el-button>
      </el-form-item>
    </el-form>
    <ele-pro-table
        ref="table"
        :where="where"
        :datasource="url"
        :columns="columns"
        height="calc(100vh - 455px)">
      <template slot="avatar" slot-scope="{row}">
        <el-avatar shape="square" :size="25" :src="row.avatar"/>
      </template>
    </ele-pro-table>
  </div>
</template>

<script>

export default {
  props: {
    id: [Number, String]
  },
  data() {
    return {
      columns: [
        {
          prop: 'id',
          label: 'ID',
          width: 60,
          align: 'center',
          showOverflowTooltip: true,
          fixed: "left"
        },
        {
          label: '头像',
          showOverflowTooltip: true,
          width: 100,
          align: 'center',
          slot: 'avatar',
        },
        {
          prop: 'name',
          label: '姓名',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center',
        },
        {
          prop: 'id_card',
          label: '学号',
          showOverflowTooltip: true,
          minWidth: 150,
          align: 'center',
        },
        {
          prop: 'school_name',
          label: '学校',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center',
        },
        {
          prop: 'grade_name',
          label: '年级',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center',
        },
        {
          prop: 'class_name',
          label: '班级',
          minWidth: 100,
          resizable: false,
          align: 'center',
        },
        {
          prop: 'total',
          label: '考勤次数',
          minWidth: 100,
          resizable: false,
          align: 'center',
        },
        {
          prop: 'create_time',
          label: '创建时间',
          showOverflowTooltip: true,
          minWidth: 120,
          align: 'center'
        }
      ],
      where: {}
    }
  },
  computed: {
    url: function () {
      return '/clazz/classLogMonth?class_id=' + this.id
    }
  },
  methods: {
    reload() {
      this.$refs.table.reload({where: this.where})
    },
    reset() {
      this.where = {}
      this.reload()
    }
  }
}
</script>
